package com.feicheng.iou.controller;


import com.feicheng.iou.commom.ReturnCode;
import com.feicheng.iou.exception.SystemException;
import com.feicheng.iou.pojo.UpdateRolePermissionPOJO;
import com.feicheng.iou.result.ResultInfo;
import com.feicheng.iou.service.RolePermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tianchunlei
 * @since 2021-06-28
 */
@RestController
@RequestMapping("/iou/rolePermission")
@Slf4j
public class RolePermissionController {

    @Autowired
    private RolePermissionService rolePermissionService; //角色权限业务实现类

    /**
     * @Author wuweinan
     * @Description //修改角色的姓名和其权限接口
     * @Date 2021/7/28 11:41
     * @Param updateRolePermissionPOJO 封装角色和要修改的权限编号
     * @return ResultInfo
     */
    @PutMapping
    public ResultInfo changeRoleAndPermission(UpdateRolePermissionPOJO updateRolePermissionPOJO){
        log.info("RolePermissionController的changeRoleAndPermission方法进入，参数updateRolePermissionPOJO：" + updateRolePermissionPOJO);
        //校验参数是否为空
        if (updateRolePermissionPOJO == null) {
            throw new SystemException(ReturnCode.PARAM_NOT_NULL);
        }

        return rolePermissionService.updateRolePermission(updateRolePermissionPOJO);
    }
}

